/*
 * NMC-nightcmusic
 * Copyright (c) 2009 nightc http://blog.nightc.com/
 * Date: 2014-11-06
 * 
 */
(function($){
    $.fn.nmc = function(options){
        //各种属性、参数
        var defaults = {
            src     : "http://musicnightc.qiniudn.com/Nyan Cat - Nyan Cat.mp3",
            control : false,
            loop    : true,
            autoplay: false,
        };
        var options = $.extend(defaults, options);
        var player;
        var control = {
            "op"    : options.control && ($(this) != undefined)?$(this):false,
            "fc"    : function (opt){
                    if(opt && control.op){
                        control.op.click(function(){
                            if(player[0].paused){
                                player[0].play();
                            } else {
                                player[0].pause();
                            }
                        });
                    }
            }
        };
        (function(){
            player = $('<audio></audio>');
            player[0].src = options.src;
            options.autoplay && player[0].play();
            player[0].loop = options.loop;
            return control;
        })().fc(options.control);
    };
})(jQuery);